<!-- 首页 -->
<template>
	<view v-if="chat_flag == 1">
		<tn-custom bgColor="bg-gradual-pink" :isBack="true">
			<!-- <block slot="left">
				<view class="btn-left" @click="shaixuan">
					<u-icon name="shaixuan" custom-prefix="iconfont"></u-icon>
					<view class="left-text">安康市</view>
				</view>
			</block> -->
			<block slot="content">筛选</block>
		</tn-custom>
		<u-grid :col="4">
			<u-grid-item @click="doNew">
				<u-icon name="heart" :size="46"></u-icon>
				<view class="grid-text">最新</view>
			</u-grid-item>
			<u-grid-item @click="doHot">
				<u-icon name="star" :size="46"></u-icon>
				<view class="grid-text">推荐</view>
			</u-grid-item>
			<u-grid-item @click="handerChooseLocation">
				<u-icon name="map" :size="46"></u-icon>
				<view class="grid-text">同城</view>
			</u-grid-item>
			<u-grid-item @click="doGold">
				<u-icon name="integral" :size="46"></u-icon>
				<view class="grid-text">贵族</view>
			</u-grid-item>
		</u-grid>
		
		<coin-popup></coin-popup>
		<user-auth></user-auth>
		<user-phone></user-phone>
		<search-popup ref="search" @query="query"></search-popup>
	</view>
</template>

<script>
import {mapState} from 'vuex';
import base from '@/config/baseUrl.js';
export default {
	components: {
		
	},
	data() {
		return {
			systemInfo: base.systemInfo,
		};
	},
	created() {
		this.init();
	},
	onShow() {
		this.$u.get('/system/config/getChatValue',{
			appId: this.website.appId,
			userId: this.vuex_user.userId,
		}).then(res => {
			this.$store.commit('setChatFlag', res.data);
			this.vuex_tabbarList[0].show = res.data;
			this.vuex_tabbarList[2].show = res.data;
			this.vuex_tabbarList[3].show = res.data;
			this.vuex_tabbarList[4].show = res.data;
			this.$store.commit('setTabbar', this.vuex_tabbarList);
		});
	},
	onShareAppMessage(res) {
		return {
			title: '送你一个对象，快来「处CP」吧！',
			path: '/pages/index/world/index',
			imageUrl: 'http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20220914/58242695c2a8421b892eced5f1bd3b15.jpeg',
		};
	},
	onShareTimeline() {
		return {
			title: '送你一个对象，快来「处CP」吧！',
			path: '/pages/index/world/index',
			imageUrl: 'http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20220914/58242695c2a8421b892eced5f1bd3b15.jpeg',
		};
	},
	computed: {
		...mapState(['vuex_user','chat_flag','vuex_tabbarList']),
	},
	methods: {
		init() {
			// 需要固定swiper的高度
			// #ifndef MP-ALIPAY
			this.height = (uni.getSystemInfoSync().screenHeight - this.systemInfo.navBarH - this.systemInfo.tabbarH - 40) + 'px'
			// #endif
		},
		shaixuan() {
			this.$refs.search.open();
		},
		doNew() {
			this.judgeLogin(() => {
				this.$u.route({
					url: '/pages/index/user/new',
				});
			});
		},
		doHot() {
			this.judgeLogin(() => {
				this.$u.route({
					url: '/pages/index/user/hot',
				});
			});
		},
		doCity() {
			this.$u.route({
				url: '/pages/index/user/city',
			});
		},
		doGold() {
			this.judgeLogin(() => {
				this.$u.route({
					url: '/pages/index/user/gold',
				});
			});
		},
		handerChooseLocation () {
		  uni.chooseLocation({
		    success: (res) => {
				this.updateLocation(res.latitude, res.longitude);
		    },
		    fail: function (err) {
		        console.log('取消按钮', err)
		    }
		  })
		},
		updateLocation(lat,lng) {
			this.$u.put('/system/user/profile',{
				lat: lat,
				lon: lng,
			}).then(res => {
				this.doCity();
			})
		},
		chong() {
			this.judgeLogin(() => {
				this.$store.commit('setCoin', true);
			});
		},
	}
};
</script>
<style lang="scss" scoped>
	page {
		background-color: #fff;
	}
	.top-box {
		display: flex;
		background-color: #fff;
		align-items: center;
		height: 40px;
		justify-content: space-between;
	}
	.u-tabs-list {
		display: flex;
		align-items: center;
		flex: 1;
	}
	.u-tabs-box {
		display: flex;
		flex: 1;
		align-items: center;
		justify-content: center;
	}
	.u-tabs {
		padding: 5px 0;
		font-size: 28rpx;
		display: flex;
	}
	.u-tabs-active {
		font-weight: bolder;
		color: #a569d9;
		border-bottom: 2px solid #a569d9;
	}
	.amount {
		font-size: 26rpx;
		margin-right: 15px;
		font-weight: bolder;
		line-height: 80rpx;
		color: #2979ff;
	}
	.user-box {
		display: flex;
		align-items: center;
		padding: 15px;
		padding-bottom: 0;
	}
	.user-name-box {
		display: flex;
		align-items: center;
	}
	.nickname {
		font-size: 28rpx;
		margin-right: 5px;
	}
	.sex-box {
		background-color: #2b85e4;
		display: flex;
		color: #fff;
		padding: 4rpx 10rpx;
		border-radius: 20px;
		font-size: 16rpx;
	}
	.sex-box-nv {
		background-color: #fe709f;
		display: flex;
		color: #fff;
		padding: 4rpx 10rpx;
		border-radius: 20px;
		font-size: 16rpx;
	}
	.user-tag-box {
		display: flex;
		align-items: center;
	}
	.user-tag {
		font-size: 20rpx;
		color: #82848a;
		margin: 10rpx 0;
	}
	.user-box-right {
		margin-left: 15px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex: 1;
	}
	.sign-name {
		font-size: 24rpx;
		color: #8d8d8d;
		text-overflow: ellipsis;
		width: 400rpx;
		overflow: hidden;
		white-space: nowrap;
	}
	.line {
		float:left;
		width: 1px;
		height: 16rpx; 
		background: #e5e5e5;
		margin: 0 5px;
	}
	.loadmore-box {
		padding: 15px;
	}
	.btn-left {
		font-size: 28rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 1px solid #e6028e;
		margin-left: 20px;
		padding: 8rpx 20rpx;
		border-radius: 20px;
	}
	.left-text {
		margin-left: 10rpx;
		font-size: 28rpx;
	}
</style>
